package com.learn.demo.lambda.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Stream;

/**
 * Stream创建方式
 *
 * @author banjiawei
 * @date 2021/06/22
 */
public class CreatorDemo {
    public static void main(String[] args) {
        Stream<String> stream = new ArrayList<String>().stream();
        Stream<String> stream1 = Arrays.stream(new String[10]);
        Stream<Integer> stream3 = Stream.iterate(0, (x) -> x + 1);
        //创建
        Stream<String> stream2 = Stream.of("a", "bb", "ccc", "dddd");
        //中间操作
        Stream<String> stream4 = stream2.filter(s -> {
            System.out.println("中间操作");
            return s.length() > 1;
        });
        //终止操作
        stream4.forEach(System.out::println);

        Stream.of("a", "bb", "ccc", "dddd").map(String::toUpperCase).forEach(System.out::println);
    }
}
